<?php


namespace app\common\business;


use app\common\lib\sms\AliSms;
use app\common\lib\sms\ClassArr;
use think\facade\Cache;

class Sms
{
    public static function sendCode($phone, $type = 'ali')
    {
        //生成验证码
        $code = rand(1000, 9999);

        $classStats = ClassArr::smsClassStat();
        $classObj = ClassArr::initClass($type, $classStats);

        $sms = $classObj::sendSms($phone, $code);

        if ($sms) {
            Cache::store('redis')->set('code_' . $phone, 'milan', 60);
            return true;
        }

        return false;
    }



}